import type { UserInfo } from '@vben/types';

import { useAccessStore } from '@vben/stores';

import { baseRequestClient, defHttp } from '#/api/request';
/**
 * 获取用户信息
 */
export async function getUserInfoApi() {
  baseRequestClient.addRequestInterceptor({
    fulfilled: async (config) => {
      const accessStore = useAccessStore();
      config.headers.Authorization = `Bearer ${accessStore.accessToken}`;
      return config;
    },
  });
  return baseRequestClient.get<UserInfo>('/getInfo');
}

// export async function getUserList() {
//   return defHttp.post<any>('/iam/users/list');
// }
export async function getUserByIds(values: any) {
  const data = Array.isArray(values[0]) ? values[0] : values;
  return defHttp.post<any>('/iam/users/ids', data);
}
